function HandlePageLastUpdatedProduce(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options;

  this._createElements();
};
HandlePageLastUpdatedProduce.prototype._createElements = function() {
  var _self = this;
  this._popupBox = new PopupBox();
  this._search = { dateFrom: null,
                   dateTo: null,
                   operator: ''
                 };
  tr = this._gui.table.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.backgroundColor = '#fff';
  td.colSpan = 7;
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._loadData();
};

HandlePageLastUpdatedProduce.prototype._loadData = function() {
  this._events = null;
  this._parameters = null;
  this._retrieveEvents(1);
};

HandlePageLastUpdatedProduce.prototype._verifyData = function() {
  if (this._events) {
    this._updateElements();
  }
};

HandlePageLastUpdatedProduce.prototype._retrieveEvents = function(page, condition, from, to, pos) {
  var _self = this;
  var args =((condition) ? '&c=' + encodeURIComponent(condition) : '') + '&p=' + page + ((from) ?  '&from=' + from : '') + ((to) ?  '&to=' + to : '') + '&b=' + JSON.stringify('{{$smarty.const.BRANCH|escape:javascript}}');
  new RequestUtils()._mysql('events', args, function(result, params) { _self._events = result.data;
                                                                       _self._parameters = result;
                                                                       _self._verifyData.call(_self);
                                                                     }, { php: Constant.FACTORY + '/customphp/mysqlcustom.php', pos: (pos) ? pos: null});
};

HandlePageLastUpdatedProduce.prototype._updateElements = function() {
  var _self = this;
  DOMUtils.removeTableRows(this._gui.table, 1);
  DOMUtils.removeChildElements(this._gui.page);

  /*---Last Updated-----*/
  if (this._events.length == 0) {
    tr = this._gui.table.insertRow(-1);
    td = tr.insertCell(-1);
    td.colSpan = 7;
    td.style.height = '25px';
    td.style.backgroundColor = '#ffffff';
    td.style.textAlign = 'center';
    td.appendChild(document.createTextNode('N/A'));
  }
  for (var j = 0, jl = this._events.length; j < jl; j++) {
    var event = this._events[j];
    tr = this._gui.table.insertRow(-1);
    new TableRowLastUpdatedProduce(tr, event, {user: this._operator, date: this._now, hidePrice: true, callback: function(pos) { _self._retrieveEvents(_self._parameters.page, _self._parameters.condition, null, null, pos);} } );
  }
  /*--PAGINATION--*/
  Pagination.makePagedResults(this._gui.page, this._parameters.page, this._parameters.total, this._parameters.size, function(page, condition) { _self._retrieveEvents.call(_self, page, _self._parameters.condition); }, this, document);
  /*----SEARCH-----*/
  this._eventSearch(this._gui, function(condition, from, to) { _self._retrieveEvents.call(_self, 1, condition, from, to); });
};

HandlePageLastUpdatedProduce.prototype._eventSearch = function(gui, callbackFunc) {
  var _self = this;
  this._callbackFunc = callbackFunc;
  gui.search.operator.value = this._search.operator;
  gui.search.operator.onchange = function() { _self._search.operator = this.value; };
  gui.search.operator.onkeydown = function() { _self._search.operator = this.value; };
  gui.search.operator.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                 if (code == 13) {
                                                   _self._callbackFunc.call(_self, _self._toString(_self._search), (_self._search.dateFrom) ? JSON.stringify(_self._search.dateFrom) : null, (_self._search.dateTo) ? JSON.stringify(_self._search.dateTo) : null);
                                                 }
                                               };
  gui.search.dateFrom.value = (this._search.dateFrom) ? SimpleDate.format(this._search.dateFrom) : '';
  gui.search.dateFrom.onclick = function() { var context = this;
                                             _self._changeDate.call(_self, this, _self._search.dateFrom, function(sd) { _self._search.dateFrom = sd; context.focus(); }, false);
                                             return false;
                                           };
  gui.search.dateFrom.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                 if (code == 13) {
                                                   _self._callbackFunc.call(_self, _self._toString(_self._search), (_self._search.dateFrom) ? JSON.stringify(_self._search.dateFrom) : null, (_self._search.dateTo) ? JSON.stringify(_self._search.dateTo) : null);
                                                 }
                                               };
  gui.search.dateTo.value = (this._search.dateTo) ? SimpleDate.format(this._search.dateTo) : '';
  gui.search.dateTo.onclick = function() { var context = this;
                                           _self._changeDate.call(_self, this, _self._search.dateTo, function(sd) { _self._search.dateTo = sd; context.focus(); }, false);
                                           return false;
                                         };
  gui.search.dateTo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                               if (code == 13) {
                                                 _self._callbackFunc.call(_self, _self._toString(_self._search), (_self._search.dateFrom) ? JSON.stringify(_self._search.dateFrom) : null, (_self._search.dateTo) ? JSON.stringify(_self._search.dateTo) : null);
                                               }
                                             };
 gui.search.search.onclick = function() { _self._callbackFunc.call(_self, _self._toString(_self._search), (_self._search.dateFrom) ? JSON.stringify(_self._search.dateFrom) : null, (_self._search.dateTo) ? JSON.stringify(_self._search.dateTo) : null); };
};

HandlePageLastUpdatedProduce.prototype._toString = function(search) {
  var str = '';
  str += (search.operator == '') ? '1 = 1' : '(e.userAccount LIKE \'%' + search.operator + '%\')';
  return str;
};

HandlePageLastUpdatedProduce.prototype._changeDate = function(label, currentDate, onChangeFunc, showTime) {
  var _self = this;
  this._wContainer = document.createElement('div');
  this._wContainer.style.left = DOMUtils.findPos(label)[0] + 'px';
  this._wContainer.style.top = DOMUtils.findPos(label)[1] + 'px';
  this._popupBox._open(this._wContainer, { pos: DOMUtils.findPos(label) });
  
  var ds = new DateSelect(currentDate, null, { container: this._wContainer, showTime: showTime });
  ds._selectFunc = function(sd) { _self._selectDate.call(_self, sd, label, onChangeFunc, showTime); };
};

HandlePageLastUpdatedProduce.prototype._selectDate = function(sd, label, onChangeFunc, showTime) {
  
  onChangeFunc(sd);
  this._showDate(sd, label, showTime);
  this._popupBox._close();
};

HandlePageLastUpdatedProduce.prototype._showDate = function(sd, label, showTime) {
  if (sd) { 
    label.value = SimpleDate.format(sd, showTime);
  } else {
    label.value = '';
  }
};